package com.pinganfu.tesla.iwallet;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.pinganfu.tesla.iwallet.session.SessionManager;
import com.pinganfu.tesla.iwallet.util.TeslaUtil;
import compinganfu.tesla.iwallet.widget.BaseActivity;
import compinganfu.tesla.iwallet.widget.EditTextWithDel;

public class LoginActivity extends BaseActivity implements OnClickListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_login);

		SessionManager sm = SessionManager.getInstance();
		TextView tvCurrentAccount = (TextView) findViewById(R.id.tv_current_account);
		tvCurrentAccount.setText(sm.getUserPref().getMobileNo());

		Button btnLogin = (Button) findViewById(R.id.btn_login);

		EditTextWithDel txtLoginPwd = (EditTextWithDel) findViewById(R.id.txt_login_pwd);
		txtLoginPwd.setActionButton(btnLogin);

		btnLogin.setOnClickListener(this);

		((TextView) findViewById(R.id.tv_other_login)).setOnClickListener(this);
		((TextView) findViewById(R.id.tv_forget_pwd)).setOnClickListener(this);
		((TextView) findViewById(R.id.tv_signin)).setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.btn_login :
				TeslaUtil.gotoActivity(LoginActivity.this, MainActivity.class);
				finish();
				break;
			case R.id.tv_forget_pwd :
				TeslaUtil.gotoActivity(LoginActivity.this, ForgetPwdActivity.class);
				break;
			case R.id.tv_other_login :
				TeslaUtil.gotoActivity(LoginActivity.this, OtherLoginActivity.class);
				break;
			case R.id.tv_signin :
				TeslaUtil.gotoActivity(LoginActivity.this, SigninActivity.class);
				break;
		}
	}
}
